package com.glodon.paas.job.server.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import ch.qos.logback.classic.util.ContextInitializer;

public class LogbackConfigListener implements ServletContextListener {

    public static final String CONFIG_LOCATION_PARAM = "logbackConfigLocation";

    public void contextInitialized(ServletContextEvent event) {
        System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY,
                event.getServletContext().getInitParameter(CONFIG_LOCATION_PARAM));
    }

    public void contextDestroyed(ServletContextEvent event) {
        System.clearProperty(ContextInitializer.CONFIG_FILE_PROPERTY);
    }
}
